home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1984-04-24 | 2.3 KB | 49 lines |
- 10 DEF SEG=&H2100 'Dependent upon your memory
- 20 ' This sample program serves as both an example and the documentation
- 30 ' for the FCBREAD.BSV routine that will read the directory of a
- 40 ' disk and present the matching file name back to the BASIC program.
- 50 ' Also available to the program is the directory information that
- 60 ' contains the size and time/date information. This routine is
- 70 ' faster than OPENing the file since it does not incur that overhead.
- 80 ' Also the user can present an arbitrary string to match on.
- 90 '
- 100 ' To use, BLOAD the routine into any available free memory. It
- 110 ' has 2 entry points (INIT and GETNEXT). INIT (offset 2) is used
- 120 ' to define the disk drive (0=default, 1=A, 2=B, ....) and the
- 130 ' pattern to be used to match on. The pattern MUST BE a string of
- 140 ' length 11; the first 8 are the filename and the last 3 are the
- 150 ' extension. A "?" is used to match any character. For example to
- 160 ' get all the BASIC files on the disk, "????????BAS" would be used
- 170 ' as the input parameter. After INIT has been called, calls to
- 180 ' GETNEXT (offset 5) are made to retrieve matching file names.
- 190 ' The two parameters are the string in which the match is returned
- 200 ' (which must be of length 14) and an INTEGER (..%) return value.
- 210 ' If the status return is <0, no more matched have been found. If
- 220 ' status >=0, it is the FILE ATTRIBUTE (as defined in the DOS Disk
- 230 ' Directory).
- 240 '
- 250 ' The INTEGER value at offsets 0,1 in the routine are the offset
- 260 ' to the directory entry for the file. For example, to obtain the
- 270 ' DATE information of the file, use the following statements:
- 280 ' B% = PEEK(0)+PEEK(1)*256 ' Get offset value
- 290 ' FDATE = PEEK(B%+26)*256 + PEEK(B%+25)
- 300 '
- 310 ' The offsets into the directory entry (25, 26 in this case) are
- 320 ' defined in the DOS manual.
- 330 '
- 340 ' The example program will print all the file names on the current
- 350 ' Directory plus their attributes.
- 360 BLOAD "fcbread.bsv",0
- 370 INIT%=2
- 380 GETNEXT%=5
- 390 FILENAME$="???????????"
- 400 DISK%=2
- 410 CALL INIT%(DISK%,FILENAME$)
- 420 FILENAME$=SPACE$(14)
- 430 CALL GETNEXT%(FILENAME$,STATUS%)
- 440 IF STATUS%<0 THEN GOTO 480
- 450 PRINT FILENAME$,STATUS%
- 460 IF STATUS%>=0 THEN GOTO 420
- 470 END
- 480 STOP
-